package main

import (
	localGrpc "grpc/protos"
	"log"
	"google.golang.org/grpc"
	"context"
	"flag"
	"fmt"
)


func main() {
	name := flag.String("name","mirchen","say hello name")
	flag.Parse()
	//AsEncodeTool()
	//作为 RPC server 使用
	lis, err := grpc.Dial("0.0.0.0:9999",grpc.WithInsecure())
	if err != nil {
		log.Fatalf("failed to dial: %v", err)
	}
	defer lis.Close()
	//发起客户端调用
	c := localGrpc.NewHelloServiceClient(lis)
	//执行方法
	r, err := c.GetResponse(context.Background(),&localGrpc.Hello{Name:*name})
	if err != nil {
		log.Fatalf("failed call %v", err)
	}
	//打印获取到的消息
	fmt.Println(r.Message)
}
